org.neo4j.index.lucene
Class LuceneReadOnlyIndexService

java.lang.Object
  extended by org.neo4j.index.impl.GenericIndexService
      extended by org.neo4j.index.lucene.LuceneReadOnlyIndexService
All Implemented Interfaces:
IndexService

public class LuceneReadOnlyIndexService
extends org.neo4j.index.impl.GenericIndexService

A version of LuceneIndexService which is read-only and will throw ReadOnlyIndexException in IndexService.index(Node, String, Object) and IndexService.removeIndex(Node, String, Object). See EmbeddedReadOnlyGraphDatabase.


Field Summary
protected static String DOC_ID_KEY
           
protected static String DOC_INDEX_KEY
           
 
Constructor Summary
LuceneReadOnlyIndexService(org.neo4j.graphdb.GraphDatabaseService graphDb)
           
 
Method Summary
 void enableCache(String key, int maxNumberOfCachedEntries)
          Enables an LRU cache for a specific index (specified by key) so that the maxNumberOfCachedEntries number of results found with getNodes(String, Object) are cached for faster consecutive lookups.
protected  org.apache.lucene.search.Query formQuery(String key, Object value)
           
protected  String getDirName()
           
protected  org.apache.lucene.document.Field.Index getIndexStrategy()
           
 int getLazySearchResultThreshold()
          (Copied from LuceneIndexService.getLazySearchResultThreshold() Returns the threshold for when a result is considered big enough to skip cache and be returned as a fully lazy iterator so that getNodes(String, Object) will return very fast and all the reading and fetching of nodes is done lazily before each step in the iteration of the returned result.
 IndexHits<org.neo4j.graphdb.Node> getNodes(String key, Object value)
          Returns all nodes indexed with key and value.
 IndexHits<org.neo4j.graphdb.Node> getNodes(String key, Object value, org.apache.lucene.search.Sort sortingOrNull)
          Just like getNodes(String, Object), but with sorted result.
 org.neo4j.graphdb.Node getSingleNode(String key, Object value)
          Returns a single node indexed with associated with key and value.
protected  void indexThisTx(org.neo4j.graphdb.Node node, String key, Object value)
           
protected  Iterator<org.neo4j.graphdb.Node> instantiateIdToNodeIterator(Iterator<Long> ids)
           
 void removeIndex(org.neo4j.graphdb.Node node, String key)
          Dissociates a node from all indexed values for the given key.
 void removeIndex(String key)
          Dissociates all key-value pairs which key is part of, i.e.
protected  void removeIndexThisTx(org.neo4j.graphdb.Node node, String key, Object value)
           
 void setLazySearchResultThreshold(int numberOfHitsBeforeLazyLoading)
          (Copied from LuceneIndexService.setLazySearchResultThreshold(int) ) Sets the threshold for when a result is considered big enough to skip cache and be returned as a fully lazy iterator so that getNodes(String, Object) will return very fast and all the reading and fetching of nodes is done lazily before each step in the iteration of the returned result.
 void shutdown()
          Shuts down the index service.
 
Methods inherited from class org.neo4j.index.impl.GenericIndexService
beginTx, getGraphDb, index, removeIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOC_ID_KEY

protected static final String DOC_ID_KEY
See Also:
Constant Field Values

DOC_INDEX_KEY

protected static final String DOC_INDEX_KEY
See Also:
Constant Field Values
Constructor Detail

LuceneReadOnlyIndexService

public LuceneReadOnlyIndexService(org.neo4j.graphdb.GraphDatabaseService graphDb)
Parameters:
graphDb - the GraphDatabaseService to use.
Method Detail

getDirName

protected String getDirName()

getIndexStrategy

protected org.apache.lucene.document.Field.Index getIndexStrategy()

enableCache

public void enableCache(String key,
                        int maxNumberOfCachedEntries)
Enables an LRU cache for a specific index (specified by key) so that the maxNumberOfCachedEntries number of results found with getNodes(String, Object) are cached for faster consecutive lookups. It's preferred to enable cache at construction time.

Parameters:
key - the index to enable cache for.
maxNumberOfCachedEntries - the max size of the cache before old ones are flushed from the cache.
See Also:
LuceneIndexService.enableCache(String, int)

indexThisTx

protected void indexThisTx(org.neo4j.graphdb.Node node,
                           String key,
                           Object value)
Specified by:
indexThisTx in class org.neo4j.index.impl.GenericIndexService

setLazySearchResultThreshold

public void setLazySearchResultThreshold(int numberOfHitsBeforeLazyLoading)
(Copied from LuceneIndexService.setLazySearchResultThreshold(int) ) Sets the threshold for when a result is considered big enough to skip cache and be returned as a fully lazy iterator so that getNodes(String, Object) will return very fast and all the reading and fetching of nodes is done lazily before each step in the iteration of the returned result. The default value is LuceneIndexService.DEFAULT_LAZY_SEARCH_RESULT_THRESHOLD.

Parameters:
numberOfHitsBeforeLazyLoading - the threshold where results which are bigger than that threshold becomes lazy.

getLazySearchResultThreshold

public int getLazySearchResultThreshold()
(Copied from LuceneIndexService.getLazySearchResultThreshold() Returns the threshold for when a result is considered big enough to skip cache and be returned as a fully lazy iterator so that getNodes(String, Object) will return very fast and all the reading and fetching of nodes is done lazily before each step in the iteration of the returned result. The default value is LuceneIndexService.DEFAULT_LAZY_SEARCH_RESULT_THRESHOLD.

Returns:
the threshold for when a result is considered big enough to be returned as a lazy iteration.

getNodes

public IndexHits<org.neo4j.graphdb.Node> getNodes(String key,
                                                  Object value)
Description copied from interface: IndexService
Returns all nodes indexed with key and value.

Parameters:
key - the key for index
value - the value for index
Returns:
nodes that have been indexed with key and value

getNodes

public IndexHits<org.neo4j.graphdb.Node> getNodes(String key,
                                                  Object value,
                                                  org.apache.lucene.search.Sort sortingOrNull)
Just like getNodes(String, Object), but with sorted result.

Parameters:
key - the index to query.
value - the value to query for.
sortingOrNull - lucene sorting behaviour for the result. Ignored if null.
Returns:
nodes that has been indexed with key and value, optionally sorted with sortingOrNull.

instantiateIdToNodeIterator

protected Iterator<org.neo4j.graphdb.Node> instantiateIdToNodeIterator(Iterator<Long> ids)

formQuery

protected org.apache.lucene.search.Query formQuery(String key,
                                                   Object value)

getSingleNode

public org.neo4j.graphdb.Node getSingleNode(String key,
                                            Object value)
Description copied from interface: IndexService
Returns a single node indexed with associated with key and value. If no such node exist null is returned. If more then one node is found a runtime exception is thrown.

Parameters:
key - the key for index
value - the value for index
Returns:
node that has been indexed with key and value or null

removeIndexThisTx

protected void removeIndexThisTx(org.neo4j.graphdb.Node node,
                                 String key,
                                 Object value)
Specified by:
removeIndexThisTx in class org.neo4j.index.impl.GenericIndexService

removeIndex

public void removeIndex(org.neo4j.graphdb.Node node,
                        String key)
Description copied from interface: IndexService
Dissociates a node from all indexed values for the given key. If no such association exists this method silently returns. Implementations may choose to not implement this method and should in such a case throw UnsupportedOperationException.

Parameters:
node - the node to dissociate from all indexed values for the given key.
key - the key in the key-value pairs to remove.

removeIndex

public void removeIndex(String key)
Description copied from interface: IndexService
Dissociates all key-value pairs which key is part of, i.e. clearing the an entire index key is cleared. Implementations may choose to not implement this method and should in such a case throw UnsupportedOperationException.

Parameters:
key - the index to clear.

shutdown

public void shutdown()
Description copied from interface: IndexService
Shuts down the index service. After this method has been invoked any following method invocation on this instance is invalid.

Specified by:
shutdown in interface IndexService
Overrides:
shutdown in class org.neo4j.index.impl.GenericIndexService


Copyright © 2010 Neo4j. All Rights Reserved.